import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */
// 注释

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'admin'
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [

  /** When your routing table is too long, you can split it into small modules**/
  // 注释

  { path: '*', redirect: '/404', hidden: true },

  {
    path: '/admin',
    component: Layout,
    meta: { title: '项目', icon: 'list' },
    hidden: true,
    children: [
      {
        path: '',
        component: () => import('@/views/index/main'),
        name: 'admin',
        meta: { title: '项目管理' }
      },
      {
        path: 'pageDb',
        component: () => import('@/views/page/page_db'),
        name: 'pageDb',
        meta: { title: '配置db' },
        hidden: true
      },
      {
        path: 'pageModel',
        component: () => import('@/views/page/page_model'),
        name: 'pageModel',
        meta: { title: '配置model' },
        hidden: true
      },
      {
        path: 'pageDao',
        component: () => import('@/views/page/page_dao'),
        name: 'PageDao',
        meta: { title: '配置dao' },
        hidden: true
      },
      {
        path: 'pageService',
        component: () => import('@/views/page/page_service'),
        name: 'pageService',
        meta: { title: 'service' },
        hidden: true
      },
      {
        path: 'pageController',
        component: () => import('@/views/page/page_controller'),
        name: 'pageController',
        meta: { title: '配置controller' },
        hidden: true
      },
      {
        path: 'pageView',
        component: () => import('@/views/page/page_view'),
        name: 'pageView',
        meta: { title: '配置view' },
        hidden: true
      },
      {
        path: 'project',
        component: () => import('@/views/page/project'),
        name: 'Project',
        meta: { title: '项目管理' },
        hidden: true
      },
      {
        path: 'Worklist',
        component: () => import('@/views/work/work_list'),
        name: 'Worklist',
        meta: { title: '列表' },
        hidden: true
      },
      {
        path: 'WorkRela',
        component: () => import('@/views/work/work_rela'),
        name: 'WorkRela',
        meta: { title: '关系配置' },
        hidden: true
      },
      // {
      //   path: 'WorkDetail',
      //   component: () => import('@/views/work/work_detail'),
      //   name: 'WorkDetail',
      //   meta: { title: '展示列表' },
      //   hidden: true
      // },
      {
        path: 'WorkPage',
        component: () => import('@/views/work/work_page'),
        name: 'WorkPage',
        meta: { title: '映射配置' },
        hidden: true
      }, {
        path: 'custom',
        component: () => import('@/views/custom/list'),
        name: 'customList',
        meta: { title: '数据定制列表' },
        hidden: true
      }
    ]
  },

  {
    path: '/style',
    component: Layout,
    meta: { title: '样式模板', icon: 'clipboard' },
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/templates/templatesSty'),
        name: 'style',
        meta: { title: '样式模板管理', roles: true }
      },
      {
        path: 'manage',
        component: () => import('@/views/templates/styleManage'),
        name: 'styleManage',
        hidden: true,
        meta: { title: '样式模板', roles: true }
      },
      {
        path: 'tdesc',
        component: () => import('@/views/work/work_styForm'),
        name: 'stytdesc',
        meta: { title: '模板集管理', roles: true },
        hidden: true
      },
      {
        path: 'append',
        component: () => import('@/views/additional/appStyAdd'),
        name: 'styappend',
        meta: { title: '附加值管理', roles: true },
        hidden: true
      },
      {
        path: 'conaddval',
        component: () => import('@/views/additional/styAdd'),
        name: 'styconadd',
        meta: { title: '验证附加值', roles: true },
        hidden: true
      },
      {
        path: '',
        component: Layout,
        redirect: 'index',
        hidden: true
      }
    ]
  },

  {
    path: '/project',
    component: Layout,
    meta: { title: '文件模板', icon: 'documentation' },
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/templates/templatesPro'),
        name: 'project',
        meta: { title: '文件模板管理', roles: true }
      },
      {
        path: 'manage',
        component: () => import('@/views/templates/projectManage'),
        name: 'projectManage',
        hidden: true,
        meta: { title: '文件模板', roles: true }
      },
      {
        path: 'conaddval',
        component: () => import('@/views/additional/proAdd'),
        name: 'proconadd',
        meta: { title: '条件附加值', roles: true },
        hidden: true
      },
      {
        path: 'append',
        component: () => import('@/views/additional/appProAdd'),
        name: 'proappend',
        meta: { title: '附加值管理', roles: true },
        hidden: true
      }, {
        path: 'tdesc',
        component: () => import('@/views/work/work_proForm'),
        name: 'protdesc',
        meta: { title: '模板集管理', roles: true },
        hidden: true
      }, {
        path: '',
        component: Layout,
        redirect: 'index',
        hidden: true
      }
    ]
  },

  {
    path: '/variable',
    component: Layout,
    meta: { title: '变量管理', icon: 'documentation' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/variable/index'),
        name: 'variable',
        meta: { title: '变量管理列表' }
      },{
        path: '',
        component: Layout,
        redirect: 'index',
        hidden: true
      }
    ]
  },

  {
    path: '/line',
    component: Layout,
    meta: { title: '连线', icon: 'documentation' },
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/line/lineIndex'),
        name: 'index',
        meta: { title: '连线' },
      }
    ]
  },

  {
    path: '/custom',
    component: Layout,
    meta: { title: '自定义数据', icon: 'clipboard' },
    hidden: true,
    children: [
      {
        path: 'save',
        component: () => import('@/views/custom/save'),
        hidden: true,
        name: 'customsave',
        meta: { title: '数据添加' }
      },
      {
        path: 'desc',
        component: () => import('@/views/custom/desc'),
        hidden: true,
        name: 'customdesc',
        meta: { title: '数据详情' }
      },
      {
        path: '',
        component: Layout,
        redirect: '/admin',
        hidden: true
      }
    ]
  },

  {
    path: '/enum',
    component: Layout,
    meta: { title: '枚举', icon: 'documentation' },
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/enum/list'),
        name: 'enumList',
        meta: { title: '枚举列表管理' }
      }, {
        path: 'desc',
        component: () => import('@/views/enum/desc'),
        name: 'enumDesc',
        meta: { title: '枚举详情' }
      }, {
        path: 'save',
        component: () => import('@/views/enum/save'),
        name: 'enumSave',
        meta: { title: '添加枚举' }
      },{
        path: '',
        component: Layout,
        redirect: 'index',
        hidden: true
      }
    ]
  },

  {
    path: '/help',
    component: Layout,
    meta: { title: '帮助', icon: 'question' },
    hidden: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/help/help_list'),
        name: 'helplist',
        meta: { title: '帮助文档列表', roles: true }
      },
      {
        path: 'form',
        component: () => import('@/views/help/help_form'),
        name: 'helpform',
        meta: { title: '修改帮助文档', roles: true },
        hidden: true

      },
      {
        path: 'add',
        component: () => import('@/views/help/help_add'),
        name: 'helpadd',
        meta: { title: '添加帮助文档', roles: true },
        hidden: true

      },
      {
        path: '',
        component: Layout,
        redirect: 'list',
        name: 'list',
        hidden: true
      }
    ]
  },



]
